﻿Imports Microsoft.VisualBasic
Imports System.Data
Partial Public Class Service

#Region "电费单据_接收单据数据"
    Public Function _ELEC_Upload(ByVal DsArr As Byte(), ByRef ErrString As String) As Boolean
        If DsArr Is Nothing Then
            ErrString = Now.ToString & "上传数据不能为空!"
            Return False
        End If
        '--还原DS
        Dim ds As New DataSet
        Dim sqlstr As String = String.Empty
        '--还原DATASET
        If FControl.DsRestore(ds, DsArr) = False Then
            ErrString = "无法解析上传的数据!"
            Return False
        End If
        '--循环读取数据
        For i As Integer = 0 To ds.Tables.Count - 1
            '--循环读取当前表的数据
            For j As Integer = 0 To ds.Tables(i).Rows.Count - 1
                '--组合查询语句
            Next
        Next
        Return True
    End Function
#End Region

#Region "电费单据_接收ACCESS数据库"
    Public Function _ELEC_UPDATEDB(ByVal FName As String, ByVal FDB As Byte()) As Boolean Implements IService._ELEC_UPDATEDB
        Try
            If FName.Trim = String.Empty Then
                Return False
            End If
            If FDB Is Nothing Then
                Return False
            End If
            '--保存
            '-路径是否存在
            If IO.Directory.Exists(AppDomain.CurrentDomain.BaseDirectory & "\App_Data" & FName) = False Then
                IO.Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory & "\App_Data" & FName)
            End If
            Dim fpath As String = AppDomain.CurrentDomain.BaseDirectory & "\App_Data" & FName & "\" & Now.ToString("yyyy_MM_dd_HH_mm_ss") & ".mdb"
            My.Computer.FileSystem.WriteAllBytes(fpath, FDB, False)
            Return True
        Catch ex As Exception

            Return False
        End Try
    End Function

#End Region

#Region "查询电费单"
    Public Function _ELEC_GetBillList(ByVal FSession As String, ByVal FClientName As String, ByVal FStartDate As Date, ByVal FEndDate As Date, ByRef DsArr As Byte(), ByRef ErrString As String) As Boolean Implements IService._ELEC_GetBillList
        Try
            Dim FUinf As New FUserInfo
            If GetUserInfoBySession(FSession, FUinf, ErrString) = False Then
                Return False
            End If
            If _User_CheckAuth(FSession, "sdf", "sdfsdf", "") = False Then
                ErrString = "没有权限!"
                Return False
            End If
            Dim Sqlstr As String = String.Format("select CustomerID '用户号',MeterNo '表号',PE '购电量',UnitPrice '单价',TotalCost '总额',PETime '购电时间',PETimes '购电次数',RE '剩余电量',ME '负电量',TotalConsume '累计用电量',[Operator] '操作员',UserName '用户名',Address '地址',Telephone '电话',Area '区域',PhaseWire '表型号',MaxLoad '限电负荷',DelayTime '倍率',AE '弱报警电量' from IC_SDJL where FClient='{0}' and PETime>='{1}' and PETime<='{2}'", FClientName, FStartDate.ToString("yyyy-MM-dd 00:00:00"), FEndDate.ToString("yyyy-MM-dd 23:59:59"))
            Dim ds As New DataSet
            If DControl.QuerySQL(Sqlstr, ds, ErrString) = False Then
                ErrString = "读取数据失败! 错误信息:" & ErrString
                Return False
            End If
            DsArr = FControl.CvtDs(ds)
            Return True
        Catch ex As Exception
            ErrString = ex.Message
            Return False
        End Try
    End Function
#End Region
End Class
